package edu.rit.teamrocket.model;

import java.util.ArrayList;


public class Recipe extends Entry
{
	private String name;
	private ArrayList<FoodItem> ingredients;


	public void addIngredient(Entry newIngredient, int numberOfUnits)
	{
		ingredients.add(new FoodItem(newIngredient, numberOfUnits));
	}

	public String getName()
	{
		return this.name;
	}

	public ArrayList<FoodItem> getIngredients() {

		return this.ingredients;

	}

	@Override
	public int getCalories()
	{

		int totalCalories = 0;

		for(int i = 0; i < ingredients.size(); i++)
		{

			totalCalories = totalCalories + ingredients.get(i).getEntry().getCalories();
		}

		return totalCalories;

	}


	@Override
	public double getFatPercentage()
	{

		double totalFatPercentage = 0;

		for(int i = 0; i < ingredients.size(); i++)
		{
			totalFatPercentage += ingredients.get(i).getEntry().getFatPercentage();
		}

		return totalFatPercentage;
	}


	@Override
	public double getCarbPercentage()
	{

		double totalCarbPercentage = 0;

		for(int i = 0; i < ingredients.size(); i++) {

			totalCarbPercentage = (int) (totalCarbPercentage + ingredients.get(i).getEntry().getCarbPercentage());

		}

		return totalCarbPercentage;
	}


	@Override
	public double getProteinPercentage()
	{
		double totalProteinPercentage = 0;

		for(int i = 0; i < ingredients.size(); i++) {

			totalProteinPercentage = (int) (totalProteinPercentage + ingredients.get(i).getEntry().getProteinPercentage());

		}

		return totalProteinPercentage;
	}

}



